﻿<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class LoginApp extends BaseApp
{
    function index()
    {
		$GLOBALS['Lang']->_get_lang('login');	
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data('prot');
		
        $this->assign('categorydata', $categorydata);			
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
        $this->assign('category_nav_data', $nav->curnav());		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = @include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
		
	        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);	
		
		
		$TB_new = &$this->_model('new');				
		$data_index_new = $TB_new->reindex();		
        $this->assign('data_index_new', $data_index_new);		
		
		$TB_prot = &$this->_model('prot');				
		$data_index_prot = $TB_prot->reindex();		
        $this->assign('data_index_prot', $data_index_prot);				
			
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
		
        $this->display('login.view.html');
    }

    function reg()
    {
		if ((!ALLOW_REGISTER) && ($GLOBALS['SCup']->SCup_name != 'admin')) 
		{   
	        $notice = &get_message(array('msg'=>CLOSE_REGISTER_REASON,'url'=>'','title'=>'提示'));
	        $notice ->display();
		}	
	
		$GLOBALS['Lang']->_get_lang('login');	
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data('prot');
		
        $this->assign('categorydata', $categorydata);			
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
        $this->assign('category_nav_data', $nav->curnav());		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = @include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);		
	        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);	
		
		
		$TB_new = &$this->_model('new');				
		$data_index_new = $TB_new->reindex();		
        $this->assign('data_index_new', $data_index_new);		
		
		$TB_prot = &$this->_model('prot');				
		$data_index_prot = $TB_prot->reindex();		
        $this->assign('data_index_prot', $data_index_prot);			    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 		
        $this->display('reg.view.html');
    }

    function regpost()
    {
		if ((!ALLOW_REGISTER) && ($GLOBALS['SCup']->SCup_name != 'admin')) 
		{   
	        $notice = &get_message(array('msg'=>CLOSE_REGISTER_REASON,'url'=>'','title'=>'提示'));
	        $notice ->display();
		}		
		$username = $_POST['username'];		
		$pwd =  $_POST['pwd'];
		$checkpwd =  $_POST['checkpwd'];		
		$emiall =  $_POST['emiall'];
						
/*		$cookie_yzimgnum = get_cookie('yzImgNum');
		$post_yzimgnum = $_POST['yzImgNum_s_yz'];
		$get_yzimgnum = $_GET['yzImgNum_s_yz'];*/
        $data=array();
        $data['username']=$username;
        $data['email']=$emiall;
        $data['password']=$pwd;
        $data['check_passwd']=$checkpwd;
	    $user = & $GLOBALS['SCup']->_get_user(); 						
	    if($user->reg($data))
		{
		
		 $notice = &get_message(array('msg'=>"注册成功!",'url'=>SITE_URL.'/?app=login&act=index','title'=>'Notice'));
		 $notice ->display();
		
		}
		else
		{


		 $notice = &get_message(array('msg'=>"注册失败!",'url'=>SITE_URL,'title'=>'Notice'));
		 $notice ->display();

		}
		

    }		
	
    function login()
    {
		
		$username = $_POST['username'];		
		$pwd =  $_POST['pwd'];
		$cookie_yzimgnum = get_cookie('yzImgNum');
		if(!isset($_POST['yzImgNum_s_yz']))
		{
		$_POST['yzImgNum_s_yz']='';
		}
		if(!isset($_GET['yzImgNum_s_yz']))
		{
		$_GET['yzImgNum_s_yz']='';
		}		
		
		$post_yzimgnum = $_POST['yzImgNum_s_yz'];
		$get_yzimgnum = $_GET['yzImgNum_s_yz'];

	    $user = & $GLOBALS['SCup']->_get_user(); 						
	    if($user->login($username,$pwd))
		{
		
          $this->index();
		
		}
		else
		{


		 $notice = &get_message(array('msg'=>"登入失败",'url'=>SITE_URL,'title'=>'Notice'));
		 $notice ->display();

		}
		

    }

    function quit()
    {
		
	   $user = & $GLOBALS['SCup']->_get_user();		
	   if($user->quit())
	   {
	   		$GLOBALS['SCup']->SCup_user_checking = false;
	   		$notice = &get_message(array('msg'=>"退出成功!",'url'=>SITE_URL.'/?app=login&act=index','title'=>'Notice', 'skip_time'=>500));
			$notice ->display();
	   }
	   else
	   {
	   $notice = &get_message(array('msg'=>'False!','url'=>'','title'=>'Notice'));
	   $notice ->display();	   
	   
	   }

	   
	   

    }
	
    function password()
    {
		$GLOBALS['Lang']->_get_lang('password');	
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = @include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);			
			$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
	        $this->assign('site_url',SITE_URL);	
        $this->display('password.view.html');

    }	

    function editpwd()
    {
		
		$data = $_POST['data'];		
		unset($data['user_id']);				
		$data['user_id'] = $GLOBALS['SCup']->SCup_user_msg['user_id'];
				
		$user = & $GLOBALS['SCup']->_get_user();	
		
	   if($user->pwd($data))
	   {
	   $notice = &get_message(array('msg'=>'Succes!','url'=>'','title'=>'Notice'));
	   $notice ->display();		   
	   
	   }
	   else
	   {
	   $notice = &get_message(array('msg'=>'False!','url'=>'','title'=>'Notice'));
	   $notice ->display();		   
	   }
	   
    }	


    function user()
    {
		$GLOBALS['Lang']->_get_lang('login');	
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = @include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 		
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
			
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);	
			$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
		
        $this->display('user.view.html');

    }	
   
}






?>